<!doctype html>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta charset="utf-8" />
    <title>Быстрый загрузчик классов Zend Framework для Yii
 - yiiext</title>
    <style type="text/css">
    /* Meyer's reset */
    html, body, div, span, applet, object, iframe,
    h1, h2, h3, h4, h5, h6, p, blockquote, pre,
    a, abbr, acronym, address, big, cite, code,
    del, dfn, em, font, img, ins, kbd, q, s, samp,
    small, strike, strong, sub, sup, tt, var,
    b, u, i, center,
    dl, dt, dd, ol, ul, li,
    fieldset, form, label, legend,
    table, caption, tbody, tfoot, thead, tr, th, td {
        margin: 0; padding: 0;
        border: 0; outline: 0;
        font-size: 100%;
        vertical-align: baseline;
        background: transparent;
    }
    body { line-height: 1; }
    ol, ul { list-style: none; }
    blockquote, q { quotes: none; }
    blockquote:before, blockquote:after,
    q:before, q:after { content: ''; content: none; }

    /* remember to define focus styles! */
    :focus { outline: 0; }

    /* remember to highlight inserts somehow! */
    ins { text-decoration: none; }
    del { text-decoration: line-through; }

    /* tables still need 'cellspacing="0"' in the markup */
    table { border-collapse: collapse; border-spacing: 0; }

/*
yiiext CSS
Alexander Makarov, sam@rmcreative.ru
*/
body {
    font: normal 10pt Arial, Helvetica, sans-serif;
    background: #fff;
    color: #555;
    text-align: center;
}

a, a:visited {
    color: #306495;
    text-decoration: none;
}

a:hover {
    color: #73471b;
    text-decoration: underline;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: bold;
    font-family: Calibri, Helvetica, Arial, sans-serif;
}

h1 {
    font-size: 1.6em;
    margin: 1em 0 .5em;
}

h2 {
    font-size: 1.5em;
    margin: 1.07em 0 .535em;
}

h3 {
    font-size: 1.4em;
    margin: 1.14em 0 .57em;
}

h4 {
    font-size: 1.3em;
    margin: 1.23em 0 .615em;
}

h5 {
    font-size: 1.2em;
    margin: 1.33em 0 .67em;
}

h6 {
    font-size: 1.1em;
    margin: 1.6em 0 .8em;
}

::selection {
    background: #d3dfee;
    color: #000;
}

::-moz-selection {
    background: #d3dfee;
    color: #000;
}

acronym, abbr {
    cursor: help;
}

label {
    cursor: pointer;
}

hr {
    height: 1px;
    color: #ccc;
    background-color: #ccc;
    border: none;
}

#content {
    width: 980px;
    margin: 0 auto;
    text-align: left;

    background: #fff;
}

/* guide content */
div.image {
    -moz-border-radius: 7px;
    -webkit-border-radius: 7px;
    -khtml-border-radius: 7px;
    border-radius: 7px;
    margin: 10px 0;
    border: 3px solid #eee;
    text-align: center;
}

div.image > p {
    background: #eee;
    margin: 0;
    font-weight: bold;
    display: block;
}

#content ul {
    list-style: disc inside;
}

#content ol {
    list-style: decimal inside;
}

#content li {
    line-height: 160%;
}

#content ul li li {
    list-style-type: circle;
}

#content ul, #content ol {
    margin: 0 0 1em 2em;
}

#content ul p, #content ol p {
    display: inline;
}

#content p {
    line-height: 160%;
    margin-bottom: 1em;
}

span.type {
    float: left;
    font-size: 1em;
    padding-right: 0.5em;
    font-weight: bold;
}

/* code */
pre {
    display: block;
    padding: 1em;
    background: #fcfcfc;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
    font-family: Consolas, "Courier New", Courier, mono;
    margin: 1em 0;
    font-size: 10pt;
    line-height: 130%;
}

code {
    border-bottom: 1px dotted #ccc;
    font-weight: bold;
    color: #666;
}

/* --- code highlighting --- */

/* html-code */
.html-hl-brackets,
.html-hl-reserved {
    color: #0000e6;
}

.html-hl-var,
.html-hl-code,
.html-hl-quotes,
.html-hl-string {
    color: #009933;
}

/* php-code */
.php-hl-inlinetags {
    font-weight: bold;
}

.php-hl-comment {
    color: #777;
}

.php-hl-quotes,
.php-hl-string {
    color: #009933;
}

.php-hl-var {
    color: #6d3206;
}

.php-hl-reserved {
    color: #00e;
}

/* css-code */
.css-hl-identifier {
    color: #007c00;
    font-weight: bold;
}

.css-hl-reserved {
    color: #0000e6;
}

/* css-sql */
.sql-hl-reserved {
    color: #0000e6;
}

.sql-hl-identifier {
    color: #007c00;
}

.sql-hl-var {
    color: #0000e6;
}

.sql-hl-quotes, .sql-hl-string {
    color: #007c00;
}
    </style>
</head>
<body>
    <div id="content">
        <h1>Быстрый загрузчик классов Zend Framework для Yii</h1>

<p>Позволяет максимально быстро загружать классы Zend Framework без использования
require_once() или Yii::import().</p>

<h2>Установка</h2>

<h3>Расширение</h3>

<p>Распаковываем расширение в <code>protected/extensions/</code>.</p>

<h3>Zend Framework</h3>

<p>Копируем директорию <code>Zend</code> фреймворка в <code>protected/vendors/</code>.
Также можно воспользоваться <a href="http://epic.codeutopia.net/pack/">сервисом, вырезающим из ZF необходимый
функционал</a>.</p>

<h3>Вырезаем require_once из ZF</h3>

<p>Это необходимо для работы расширения и позволяет быстрее загружать классы ZF.</p>

<p>Через поиск-замену в IDE: <code>require_once</code> заменяем на <code>//require_once</code>.</p>

<p>Если у вас есть под рукой консоль, то можно воспользоваться её возможностями:</p>

<p>GNU:</p>

<pre>% cd path/to/ZendFramework/library
% find . -name '*.php' -not -wholename '*/Loader/Autoloader.php' \
  -not -wholename '*/Application.php' -print0 | \
  xargs -0 sed --regexp-extended --in-place 's/(require_once)/\/\/ \1/g'
</pre>

<p>MacOSX:</p>

<pre>% cd path/to/ZendFramework/library
% find . -name '*.php' | grep -v './Loader/Autoloader.php' | \
xargs sed -E -i~ 's/(require_once)/\/\/ \1/g'
% find . -name '*.php~' | xargs rm -f
</pre>

<h3>Изменяем index.php</h3>

<p>До запуска приложения необходимо зарегистрировать загрузчик:</p>

<div class="hl-code"><div class="php-hl-main"><pre><span class="php-hl-reserved">define</span><span class="php-hl-brackets">(</span><span class="php-hl-quotes">'</span><span class="php-hl-string">YII_DEBUG</span><span class="php-hl-quotes">'</span><span class="php-hl-code">, </span><span class="php-hl-reserved">true</span><span class="php-hl-brackets">)</span><span class="php-hl-code">;
</span><span class="php-hl-var">$webRoot</span><span class="php-hl-code">=</span><span class="php-hl-identifier">dirname</span><span class="php-hl-brackets">(</span><span class="php-hl-reserved">__FILE__</span><span class="php-hl-brackets">)</span><span class="php-hl-code">;
</span><span class="php-hl-reserved">require_once</span><span class="php-hl-brackets">(</span><span class="php-hl-identifier">dirname</span><span class="php-hl-brackets">(</span><span class="php-hl-var">$webRoot</span><span class="php-hl-brackets">)</span><span class="php-hl-code">.</span><span class="php-hl-quotes">'</span><span class="php-hl-string">/framework/yii.php</span><span class="php-hl-quotes">'</span><span class="php-hl-brackets">)</span><span class="php-hl-code">;
</span><span class="php-hl-var">$configFile</span><span class="php-hl-code">=</span><span class="php-hl-var">$webRoot</span><span class="php-hl-code">.</span><span class="php-hl-quotes">'</span><span class="php-hl-string">/../protected/config/main.php</span><span class="php-hl-quotes">'</span><span class="php-hl-code">;
</span><span class="php-hl-var">$app</span><span class="php-hl-code"> = </span><span class="php-hl-identifier">Yii</span><span class="php-hl-code">::</span><span class="php-hl-identifier">createWebApplication</span><span class="php-hl-brackets">(</span><span class="php-hl-var">$configFile</span><span class="php-hl-brackets">)</span><span class="php-hl-code">;
 
</span><span class="php-hl-identifier">Yii</span><span class="php-hl-code">::</span><span class="php-hl-identifier">import</span><span class="php-hl-brackets">(</span><span class="php-hl-quotes">&quot;</span><span class="php-hl-string">ext.yiiext.components.zendAutoloader.EZendAutoloader</span><span class="php-hl-quotes">&quot;</span><span class="php-hl-code">, </span><span class="php-hl-reserved">true</span><span class="php-hl-brackets">)</span><span class="php-hl-code">;
 
</span><span class="php-hl-comment">//</span><span class="php-hl-comment"> you are able to load custom code that is using Zend class naming convention</span>
<span class="php-hl-comment">//</span><span class="php-hl-comment"> with different prefix</span>
<span class="php-hl-identifier">EZendAutoloader</span><span class="php-hl-code">::</span><span class="php-hl-var">$prefixes</span><span class="php-hl-code"> = </span><span class="php-hl-reserved">array</span><span class="php-hl-brackets">(</span><span class="php-hl-quotes">'</span><span class="php-hl-string">Zend</span><span class="php-hl-quotes">'</span><span class="php-hl-code">, </span><span class="php-hl-quotes">'</span><span class="php-hl-string">Custom</span><span class="php-hl-quotes">'</span><span class="php-hl-brackets">)</span><span class="php-hl-code">;
</span><span class="php-hl-identifier">Yii</span><span class="php-hl-code">::</span><span class="php-hl-identifier">registerAutoloader</span><span class="php-hl-brackets">(</span><span class="php-hl-reserved">array</span><span class="php-hl-brackets">(</span><span class="php-hl-quotes">&quot;</span><span class="php-hl-string">EZendAutoloader</span><span class="php-hl-quotes">&quot;</span><span class="php-hl-code">, </span><span class="php-hl-quotes">&quot;</span><span class="php-hl-string">loadClass</span><span class="php-hl-quotes">&quot;</span><span class="php-hl-brackets">)</span><span class="php-hl-brackets">)</span><span class="php-hl-code">;
 
</span><span class="php-hl-var">$app</span><span class="php-hl-code">-&gt;</span><span class="php-hl-identifier">run</span><span class="php-hl-brackets">(</span><span class="php-hl-brackets">)</span><span class="php-hl-code">;</span></pre></div></div>
        <hr />
        <p style="text-align: right;">© 2009 — 2010, <a href="http://code.google.com/p/yiiext/">yiiext team</a>.</p>        
    </div>
</body>
</html>
